﻿

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[AreArticoleAliniateGenerate]
(
	-- Add the parameters for the function here
	@Cont TipCont,
	@CodUnitate smallint
)
RETURNS bit
AS
BEGIN
	-- Declare the return variable here
	DECLARE @ResultVar int
	SET @ResultVar=0
	-- Add the T-SQL statements to compute the return value here
	 select @ResultVar =COUNT(*) from [Conturi] c JOIN [ArticoleAliniate] a ON c.CodUnitate=a.CodUnitate
	 AND [Cont]=LTRIM(RTRIM(@Cont)) + '.'+[artAl]
	 WHERE c.CodUnitate=@CodUnitate AND a.CodUnitate=@CodUnitate
	
	
	-- Return the result of the function
	RETURN CASE WHEN @ResultVar <> 0 THEN 1 ELSE 0 END

END